package solver;

import model.Problem;
import model.Solution;
import util.Chronograph;

public class CGHillClimber extends BaseHeuristicSolver {

	public CGHillClimber(Problem problem, Solution initialSolution) {
		super(problem, initialSolution);
		name = "HillClimber";
	}

	@Override
	public int solveWithTimeLimit(int seconds) {
		Chronograph chronos = new Chronograph();
		chronos.reset();
		startSolution();
		int c = 0;
		do {
			makeNextMove();
			if (saveCurrentToBest()) {
				finishIteration(true, true);
				System.out.printf("Better solution found cost = %d\n",
						best_cost);
			}
			c++;
			if (c % 1000 == 0)
				chronos.lap();
		} while (chronos.getElapsedTimeInSeconds() < seconds);
		return 0;
	}

}
